<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@include file="/context/mytags.jsp"%>
<t:base type="jquery,easyui,tools,DatePicker"></t:base>
<link rel="stylesheet" href="plug-in/ace2/assets/css/font-awesome.min.css" />
<div class="easyui-layout" fit="true">
  <div region="center" style="padding:0px;border:0px">
  <t:datagrid name="deviceTypeList" checkbox="true" fitColumns="true" title="设备信息" actionUrl="deviceOverallController.do?datagrid" idField="id" fit="true" queryMode="group">
   <t:dgCol title="主键"  field="id"  hidden="true"  queryMode="single" width="120"></t:dgCol>
   <t:dgCol title="编号"  field="no"  queryMode="single" query="true"  width="120" ></t:dgCol> 
   <t:dgCol title="名称"  field="name"  queryMode="single" query="true"  width="120" ></t:dgCol>
   <t:dgCol title="型号"  field="model"  queryMode="single"  width="120" ></t:dgCol> 
   <t:dgCol title="数量"  field="balance"  queryMode="single"  width="120" ></t:dgCol> 
   <t:dgCol title="单位"  field="unit"  queryMode="single"  width="120" ></t:dgCol> 
   <t:dgCol title="实验室"  field="lab.name"  queryMode="single" query="true" replace="${labNames }" width="120" ></t:dgCol> 
   <t:dgCol title="所属项目"  field="teachItem.itemName"  queryMode="single"  width="120"></t:dgCol> 
   <t:dgCol title="位置"  field="location"  queryMode="single"  width="100"></t:dgCol> 
   <t:dgCol title="状态"  field="state.name"    queryMode="single"  width="60" align="center"></t:dgCol>
   <t:dgCol title="所属管理员"  field="holder.realName"    queryMode="single"  width="80"></t:dgCol>
   <t:dgToolBar title="查看" icon="icon-search" url="deviceTypeController.do?goUpdate" funname="detail" width="900"></t:dgToolBar>
   <t:dgCol title="操作" field="opt" width="160"></t:dgCol>   
   <t:dgToolBar title="打印标签" icon="icon-print"  funname="doBatchPrint" height="260" width="460"></t:dgToolBar>
  </t:datagrid>
  </div>
 </div>
  
 
 <!-- 嵌入打印插件 -->
<div id="divvideo1">
<object id="embed1" width=0 height=0 classid="clsid:CA0E44CF-B08E-4774-BD2C-0FB762F17EA9"> </object>
</div>
 
  <script type="text/javascript">
  
  function isIE() {
	    if (!!window.ActiveXObject || "ActiveXObject" in window)  
	        return true;  
	    else  
	        return false;  
	} 
  
 $(document).ready(function(){
	 if(!isIE()){
	 	document.getElementById("divvideo1").innerHTML="<embed id='embed1' type='application/mozilla-barcode-plugin' width=0 height=0></embed>";
	 }
 });
 
 function printCode(name,model,num){
	 var embed1 = document.getElementById('embed1');
	 try{
		 var ret=embed1.SetJson("[{\"name\":\""+name+"\",\"model\":\""+model+"\",\"id\":\""+num+"\"}]",0,0,0,0,0);	 
	 }catch(e){
		 alert(e)
		 alert("暂不支持当前浏览器进行打印，请使用IE浏览器或firefox或chorme内核45一下版本或360安全浏览器");
	 }
	 
 }
 

 function doBatchPrint(title,url,gname){
	 
	    var ids = [];
	    var rows = $("#deviceTypeList").datagrid('getSelections');
	    if (rows.length > 0) {
	  		var str = "";
	  		for(var i=0;i<rows.length;i++){
	  			var row = rows[i];
	  			var name = row.name;
	  			var model = row.model;
	  			var num = row.no;
	  			str +="{\"name\":\""+name+"\",\"model\":\""+model+"\",\"id\":\""+num+"\"}";
	  			if(i != rows.length -1){
	  				str +=",";
	  			}	  			
	  		}
	  		
	  		var json = "["+str+"]";
	  		 var embed1 = document.getElementById('embed1');
	  		 try{
	  			 var ret=embed1.SetJson(json,0,0,0,0,0);	 
	  		 }catch(e){
	  			 alert("暂不支持当前浏览器进行打印，请使用IE浏览器或firefox或chorme内核45一下版本或360安全浏览器");
	  		 }
	  		
		} else {
			tip("请选择需要打印的设备");
		}
 }
 
 
 </script>
 